package Chapter6.one_to_one;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "city_chapter6")
public class City implements Serializable {
	private static final long serialVersionUID = 1L;
	private long ids;
	private String nameCity;
	private Street street;

	public City() {
	}

	public City(String nameCity, Street street) {
		this.nameCity = nameCity;
		this.street = street;
	}

	@Id
	@GeneratedValue
	public long getIds() {
		return ids;
	}

	public void setIds(long ids) {
		this.ids = ids;
	}

	public String getNameCity() {
		return nameCity;
	}

	public void setNameCity(String nameCity) {
		this.nameCity = nameCity;
	}

	@OneToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "street_id")
	public Street getStreet() {
		return street;
	}

	public void setStreet(Street street) {
		this.street = street;
	}

}
